# encoding: UTF-8
"""

@author = 李林名
@email = lishuai1199@qq.com
@create_time = 2022/11/17 22:30

"""
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

# 1.创建 WebDriver 对象
wd = webdriver.Chrome()

# 2.调用WebDriver 对象的get方法 可以让浏览器打开指定网址
wd.get('https://www.baidu.com/?tn=88093251_70_hao_pg')

# 3.子代元素: 父元素>子元素  父元素 孙元素
# 获取百度官网首页左上角的 "新闻","地图","贴吧","图片"
elements=wd.find_elements(By.CSS_SELECTOR,'#s-top-left a')
for element in elements:
    print(element.get_attribute("innerText"))

print("-----------------------")

# ## 获取"查看全部百度产品"
# element=wd.find_element(By.CSS_SELECTOR,".s-top-more-btn .s-top-tomore>a")
# print(element.get_attribute("innerText"))
sleep(2)
